package dormouse.vfs.ui;

import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import org.apache.commons.vfs2.FileObject;

import dormouse.vfs.ui.renderers.FileListTableBean;

/**
 * This panel allows you to display file lists side-by-side, and copy
 * or move selected files to the other file system.
 * 
 * 
 * @author Mark
 *
 */
public class SideBySideView extends JPanel{

	/**
	 * 
	 */
	private static final long serialVersionUID = 2559288217300391692L;
	private JScrollPane leftScroller = null;
	private JScrollPane rightScroller = null;
	private FileListTableBean leftFileTable = null;
	private FileListTableBean rightFileTable = null;
	private JPanel centerPanel = null;
	private JButton copyRight = null;
	private JButton copyLeft = null;
	private FileObject leftDir = null;
	private FileObject rightDir = null;
	private JButton moveLeftBtn = null;
	private JButton moveRightBtn = null;
	
	public SideBySideView(FileObject leftDir, FileObject rightDir){
		this.leftDir = leftDir;
		this.rightDir = rightDir;
	}


	public SideBySideView(){
		
	}
	
	
		

	/**
	 * This method initializes			this.setLayout(new BorderLayout());
 this
	 * 
	 */
	private void initialize() {
        this.setLayout(new BorderLayout());
        this.setSize(new java.awt.Dimension(864,268));
        this.add(getLeftScroller(), java.awt.BorderLayout.WEST);
        this.add(getRightScroller(), java.awt.BorderLayout.EAST);
        this.add(getCenterPanel(), java.awt.BorderLayout.CENTER);
			
	}


	/**
	 * This method initializes leftScroller	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getLeftScroller() {
		if (leftScroller == null) {
			leftScroller = new JScrollPane();
			leftScroller.setPreferredSize(new java.awt.Dimension(389,323));
			leftScroller.setViewportView(getLeftFileTable());
		}
		return leftScroller;
	}


	/**
	 * This method initializes rightScroller	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getRightScroller() {
		if (rightScroller == null) {
			rightScroller = new JScrollPane();
			rightScroller.setPreferredSize(new java.awt.Dimension(389,323));
			rightScroller.setViewportView(getRightFileTable());
		}
		return rightScroller;
	}


	/**
	 * This method initializes leftFileTable	
	 * 	
	 * @return org.apache.commons.vfs.ui.FileListTableBean	
	 */
	private FileListTableBean getLeftFileTable() {
		if (leftFileTable == null) {
			leftFileTable = new FileListTableBean();
			leftFileTable.setPreferredSize(new java.awt.Dimension(200,364));
		}
		return leftFileTable;
	}


	/**
	 * This method initializes rightFileTable	
	 * 	
	 * @return org.apache.commons.vfs.ui.FileListTableBean	
	 */
	private FileListTableBean getRightFileTable() {
		if (rightFileTable == null) {
			rightFileTable = new FileListTableBean();
			rightFileTable.setPreferredSize(new java.awt.Dimension(200,264));
		}
		return rightFileTable;
	}


	/**
	 * This method initializes centerPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getCenterPanel() {
		if (centerPanel == null) {
			centerPanel = new JPanel();
			centerPanel.setPreferredSize(new java.awt.Dimension(97,133));
			centerPanel.add(getCopyRight(), null);
			centerPanel.add(getCopyLeft(), null);
			centerPanel.add(getMoveLeftBtn(), null);
			centerPanel.add(getMoveRightBtn(), null);
		}
		return centerPanel;
	}


	/**
	 * This method initializes copyRight	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getCopyRight() {
		if (copyRight == null) {
			copyRight = new JButton();
			copyRight.setText("copy >");
			copyRight.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					
				}
			});
		}
		return copyRight;
	}


	/**
	 * This method initializes copyLeft	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getCopyLeft() {
		if (copyLeft == null) {
			copyLeft = new JButton();
			copyLeft.setText("< copy");
			copyLeft.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					
				}
			});
		}
		return copyLeft;
	}


	/**
	 * This method initializes moveLeftBtn	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getMoveLeftBtn() {
		if (moveLeftBtn == null) {
			moveLeftBtn = new JButton();
			moveLeftBtn.setText("move >");
		}
		return moveLeftBtn;
	}


	/**
	 * This method initializes moveRightBtn	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getMoveRightBtn() {
		if (moveRightBtn == null) {
			moveRightBtn = new JButton();
			moveRightBtn.setText("< move");
		}
		return moveRightBtn;
	}
}  //  @jve:decl-index=0:visual-constraint="107,10"
